package com.tambapps.p2p.fandem.handshake

import com.tambapps.p2p.fandem.model.FileData
import com.tambapps.p2p.speer.exception.HandshakeFailException


class SenderHandshakeData(var files: List<FileData>) {

    @Throws(HandshakeFailException::class)
    fun validate() {
        if (files == null || files.isEmpty()) {
            throw HandshakeFailException("Sender should have sent files")
        }
        for (fileData in files) {
            if (fileData.fileName == null) {
                throw HandshakeFailException("Sender should have sent file_name")
            }
            if (fileData.fileSize == 0L) {
                throw HandshakeFailException("Sender should have sent file_size")
            }
        }
    }
}
